/**
 * Created by hiibook on 2017/6/15.
 */
var mysql  = require('mysql');
var config=require("../config/config");
module.exports=function (req,res,next) {
    console.log("判断是否为注册用户");
    var connection = mysql.createConnection(config.mysql);
    connection.connect();
    var query = connection.query("SELECT * FROM ss_user where open_id like " + "'" + req.wechatMsg.FromUserName + "'");
    query
        .on('error',function (err) {
            console.log('数据库连接失败',err)
        })
        .on('result',function (row) {
            req.wechatUserInfo = row;
        })
        .on('end',function () {
            if(req.wechatUserInfo){
                req.wechatUserStatus = true
            }else{
                req.wechatUserStatus = false
            }
            req.mysqlConnection = connection ;
            next();
        })

};